package com.goldsprite.gameframeworks.assets;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;

public class FontUtils {
	public static String fnt1Path = "fonts/ZhengQingKeZhiYaTiRegular-2.ttf";
	public static String fnt2Path = "fonts/NotoSansMonoCJKsc-Regular.otf";
	public static String fnt2_1Path = "fonts/NotoSansMonoCJKsc-Regular_500.otf";
	public static String fnt3Path = "fonts/pixelFont-7-8x14-sproutLands.ttf";
	public static String fnt4Path = "fonts/ipix_12px_6000.ttf";
	public static String fnt5Path = "fonts/QingNiaoHuaGuangJianMeiHei-2.ttf";
	public static String fnt6Path = "fonts/HYSongYunLangHeiW-1.ttf";
	public static String fnt7Path = "fonts/SanJiHuaChaoTi-Cu-2.ttf";
	public static String fnt8Path = "fonts/ark-pixel-10px-monospaced-zh_cn.ttf";
	public static String fntPath = fnt6Path;

	public static int defaultFntSize = 30;

	public static float clarityFntSizeRatio = 30;

	private static FontUtils instance;

	public static BitmapFont generate() {
		return generate(defaultFntSize);
	}

	public static BitmapFont generate(int fntSize) {
		return generate(fntSize, 1);
	}
	public static BitmapFont generateAutoClarity(int fntSize) {
		return generateAutoClarity(fntSize, fntPath);
	}
	public static BitmapFont generateAutoClarity(int fntSize, String fntPath) {
		return generate(fntSize, clarityFntSizeRatio / fntSize, fntPath);
	}
	public static BitmapFont generate(int fntSize, float clarity) {
		return generate(fntSize, clarity, fntPath);
	}
	public static BitmapFont generate(int fntSize, float clarity, String fntPath) {
		// 加载字体
		FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(fntPath));
		FreeTypeFontParameter parameter = new FreeTypeFontParameter();
		parameter.size = Math.round(fntSize * clarity); // 字体大小
		parameter.mono = false;
		parameter.incremental = true;
		parameter.color = com.badlogic.gdx.graphics.Color.WHITE;
		BitmapFont fnt = generator.generateFont(parameter);
		fnt.getData().setScale(1/clarity);
		return fnt;
	}
}
